<template>
    <div class="d_main">
    <div class="printBox">
      <printBox ref="printBox" :list="boxList"></printBox>
    </div>
    <div class="printBox">
      <print-model ref="printModel" :product-from="prinftMass"></print-model>
    </div>
      <!-- 操作区 S-->
      <div class="d_operationBox">
        <div class="d_btn">
          <el-button
            type="primary"
            size="small"
            icon="el-icon-plus"
            @click="newAddClick"
            v-permission="'MenuCode4-1-1'"
            >成品缴库</el-button
          >
          <el-button
            type="primary"
            size="small"
            icon="el-icon-plus"
            @click="newAddhalfClick"
            v-permission="'MenuCode4-1-2'"
            >半成品缴库</el-button
          >
          <selectProductOrder
            :per-visible.sync="showOrder"
            :query-action="3"
            @current="selectCurrentRow"
          />
        </div>
        <div class="d_search">
          <screec
            v-model="search.QueryDataBaseFiled"
            :headData.sync="tableHead"
            :disabled="searchLoading"
          ></screec>
          <el-input
            v-model="search.likeWords"
            placeholder="请输入关键字"
            size="small"
            @keyup.enter.native="getAllMaterils"
          >
            <el-button
              slot="append"
              :loading="searchLoading"
              type="primary"
              icon="el-icon-search"
              :disabled="searchLoading"
              element-loading-spinner="el-icon-loading"
              @click="getAllMaterils"
            >
              搜索
            </el-button>
          </el-input>
        </div>
      </div>
      <!-- 操作区 E-->
      <!-- 表格操作区 S-->
      <div class="d_tableOperation">
        <div class="d_condition"></div>
        <div class="d_set">
          <div @click="Refresh"><i class="d_icon el-icon-refresh-right" /></div>
          <div class="setting flex">
            <HeadSeting
              :list-data.sync="tableHead"
              :table-code="$config.producehandinbilllist"
              @reset="getTableHead"
            />
          </div>
        </div>
      </div>
      <!-- 表格操作区 E-->
      <!--table板块-->
      <div ref="tableCon" class="tableCon expandBox">
        <el-table
          v-show="tableHead.length > 0"
          id="emtable"
          ref="multipleTable"
          v-loading="searchLoading"
          :data="allMaterirls"
          :height="tableHeight || 'auto'"
          border
          fit
          style="width: 100%"
          @header-dragend="surverWidth"
        >
          <template v-for="(fruit, index) in tableHead">
            <el-table-column
              v-if="fruit.visible"
              :key="index"
              :label="fruit.columnName"
              :min-width="fruit.columnWidth || 90"
              :prop="fruit.columnCode"
              show-overflow-tooltip
              :fixed="fruit.isFloat ? 'left' : false"
            >
              <template slot-scope="scope">
                <el-button
                  v-if="fruit.columnCode === 'saleOrderNo'"
                  type="text"
                  @click="checkProductList(scope.row)"
                >
                  {{ scope.row[fruit.columnCode] }}</el-button
                >
                <div
                  v-else-if="fruit.columnCode === 'handInBillStateName'"
                  class="felx"
                >
                  <template v-if="scope.row.handInBillState === 0">
                    <span class="mr5 spot" style="background: #3f61f1"></span>
                    <span>{{ scope.row[fruit.columnCode] }}</span>
                  </template>
                  <template
                    v-else-if="
                      scope.row.handInBillState === 1 ||
                      scope.row.handInBillState === 3
                    "
                  >
                    <span class="mr5 spot" style="background: #67c23a"></span>
                    <span>{{ scope.row[fruit.columnCode] }}</span>
                  </template>
                  <template v-else>
                    <span class="mr5 spot" style="background: #999aaa"></span>
                    <span>{{ scope.row[fruit.columnCode] }}</span>
                  </template>
                </div>
                <div
                  v-else-if="fruit.columnCode === 'inStockStateName'"
                  class="felx"
                >
                  <template v-if="scope.row.inStockState === 0">
                    <span class="mr5 spot" style="background: #3f61f1"></span>
                    <span>{{ scope.row[fruit.columnCode] }}</span>
                  </template>
                  <template v-else-if="scope.row.inStockState === 1">
                    <span class="mr5 spot" style="background: #67c23a"></span>
                    <span>{{ scope.row[fruit.columnCode] }}</span>
                  </template>
                  <template v-else>
                    <span class="mr5 spot" style="background: #e13335"></span>
                    <span>{{ scope.row[fruit.columnCode] }}</span>
                  </template>
                </div>
                <template v-else>
                  {{ scope.row[fruit.columnCode] }}
                </template>
              </template></el-table-column
            >
          </template>
          <el-table-column fixed="right" label="操作" width="70px" align="center">
            <template slot-scope="scope">
              <div>
                <el-popover
                  :ref="`popover-${scope.$index}`"
                  placement="bottom-end"
                  popper-class="tableOp"
                  width="160"
                  :popper-options="{
                    boundariesElement: 'opBox',
                    removeOnDestroy: true,
                  }"
                  trigger="click"
                >
                  <div class="operation">
                    <ul>
                      <li @click="handleClick(scope.row)">查看</li>
                      <li @click="handlePrintBox(scope.row)">打印装箱单</li>
                      <li
                        v-show="scope.row.handInBillState === 0"
                        v-permission="'MenuCode4-1-3'"
                        @click="handleUpdata(scope.row)"
                      >
                        修改
                      </li>
                    </ul>
                    <ul>
                      <li
                        v-show="scope.row.handInBillState === 0"
                        v-permission="'MenuCode4-1-4'"
                        @click="handleConfirm(scope.row)"
                      >
                        确认
                      </li>
                      <li
                        v-show="
                          scope.row.handInBillState === 1 &&
                          scope.row.inStockState === 0
                        "
                        v-permission="'MenuCode4-1-6'"
                        @click="handleDone(scope.row)"
                      >
                        作废
                      </li>
                      <li
                        v-show="scope.row.handInBillState === 2"
                        v-permission="'MenuCode4-1-7'"
                        @click="handleCopy(scope.row)"
                      >
                        复制
                      </li>
                    </ul>
                    <ul>
                      <li
                        v-show="scope.row.handInBillState === 0"
                        v-permission="'MenuCode4-1-5'"
                        @click="handleDelete(scope.row)"
                      >
                        删除
                      </li>
                    </ul>
                  </div>
                  <div slot="reference" class="opBox pointer">
                    <span class="el-icon-more c_3F61F1" />
                  </div>
                </el-popover>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <!-- 骨架屏     -->
        <div v-if="tableHead.length == 0" class="p16">
          <el-skeleton :rows="6" animated />
        </div>
      </div>
      <!-- 分页 S-->
      <div class="d_pag">
        <pagination
          :total="total || 0"
          :page.sync="search.pageIndex"
          :limit.sync="search.pageSize"
          @pagination="getAllMaterils"
        />
      </div>
      <!-- 分页 E-->
      <!-- 人员寻找弹框   -->
      <per-redio-dialog
        :per-visible.sync="isperShow"
        @getEmployee="getEmployee"
      />
      <el-dialog
        :title="tname"
        :visible.sync="isAddProduct"
        :close-on-click-modal="false"
        custom-class="bodyNoPadDialog bigDialog"
        width="85%"
        @close="closeDialog"
        @open="openCp"
      >
        <div class="dialogDody">
          <div class="subTip">
            <span class="mr15"
              ><span class="mr5">缴库单号：</span
              >{{ ProductForm.handInBillNo || "系统自动生成" }}</span
            >
            <span class="mr15"
              ><span class="mr5">创建日期：</span
              >{{ ProductForm.createDate || dayjs().format("YYYY-MM-DD") }}</span
            >
            <span class="mr15"
              ><span class="mr5">创建人员：</span
              >{{ opsid != 1 ? ProductForm.createPersonName : name }}</span
            >
          </div>
          <div class="addWuliaoBox">
            <el-form
              ref="ProductForm"
              :model="ProductForm"
              :rules="rules"
              label-width="110px"
              label-position="left"
              class="dialogForm dialogInlineForm"
              :disabled="canDiable"
            >
              <el-row>
                <el-col :span="8">
                  <el-form-item label="缴库类型" prop="purchaseType">
                    <el-input
                      v-model="ProductForm.handInTypeName"
                      placeholder="缴库类型"
                      size="mini"
                      disabled
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="关联单据">
                    <div class="flex flex_center">
                      <div class="flex1">
                        <el-input
                          v-model="ProductForm.xieYiShuHao"
                          placeholder="关联单据"
                          size="mini"
                          disabled
                        />
                      </div>
                      <div class="ml10" />
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="缴库人员" prop="handInPersonName">
                    <div class="flex flex_center">
                      <div class="flex1">
                        <el-input
                          v-model="ProductForm.handInPersonName"
                          size="mini"
                          placeholder="请选择人员"
                        >
                          <el-button
                            slot="append"
                            icon="el-icon-user"
                            @click="isperShow = true"
                          />
                        </el-input>
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="所属客户" prop="customerName">
                    <div class="flex flex_center">
                      <div class="flex1">
                        <el-input
                          v-model="ProductForm.customerName"
                          placeholder="所属客户"
                          size="mini"
                          disabled
                        />
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="产品名称" prop="productName">
                    <div v-if="packageGuiGeType === 1" class="flex flex_center">
                      <div class="flex1 mr10">
                        <el-input
                          v-model="ProductForm.productName"
                          placeholder="产品名称"
                          size="mini"
                          disabled
                        />
                      </div>
                    </div>
                    <div v-if="packageGuiGeType === 2" class="flex flex_center">
                      <div class="flex1 mr10">
                        <el-input
                          v-model="ProductForm.productName"
                          placeholder="选择名称"
                          size="mini"
                          disabled
                        />
                      </div>
                      <div v-if="!canDiable" class="ml10 mr10">
                        <el-button
                          type="primary"
                          size="mini"
                          icon="el-icon-search"
                          @click="addbcp"
                          >查找</el-button
                        >
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="产品单位" prop="productUnion">
                    <div class="flex flex_center">
                      <div class="flex1">
                        <el-input
                          v-model="ProductForm.productUnit"
                          placeholder="产品单位"
                          size="mini"
                          disabled
                        />
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="客户单号" prop="purchaseType">
                    <el-input
                      v-model="ProductForm.customerBillNo"
                      placeholder="客户单号"
                      size="mini"
                      disabled
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="版本版面">
                    <div class="flex flex_center">
                      <div class="flex1">
                        <el-input
                          v-model="ProductForm.productVersion"
                          size="mini"
                          placeholder="版本版面"
                          disabled
                        >
                        </el-input>
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="8">
                  <el-form-item label="产品编码">
                    <div  class="flex flex_center">
                      <div class="flex1 mr10">
                        <el-input v-model="ProductForm.productCode" placeholder="产品编码" size="mini" disabled />
                      </div>
                    </div>
                  </el-form-item>
                </el-col> -->
              </el-row>
              <el-form-item label="缴库备注" class="inlineText">
                <el-input
                  v-model="ProductForm.handInRemark"
                  type="textarea"
                  :rows="1"
                  placeholder="缴库备注"
                  size="mini"
                  clearable
                />
              </el-form-item>
            </el-form>
            <div class="tableBox">
              <div class="tt flex flex_between">
                <span class="fw">成品明细</span>
                <span
                  v-if="!canDiable"
                  class="c_3F61F1 mr15 pointer"
                  @click="handlePacking"
                  ><i class="el-icon-plus mr5" /> 选择包装</span
                >
              </div>
              <div ref="bigdialogTable" class="bigdialogTbCon">
                <el-table
                  :data="ProductForm.mxDataList"
                  border
                  style="width: 100%"
                >
                  <el-table-column
                    prop="cartonSizeName"
                    label="纸箱规格"
                    width="120"
                  />
                  <el-table-column
                    label="包装描述"
                    prop="packageDescription"
                    show-overflow-tooltip
                    min-width="100"
                  />
                  <el-table-column
                    label="每箱数量"
                    prop="eachBoxQuantity"
                    show-overflow-tooltip
                    min-width="100"
                  />
                  <el-table-column
                    label="实际数量"
                    prop="handInQuantity"
                    show-overflow-tooltip
                    min-width="90"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.handInQuantity"
                        :disabled="canDiable"
                        placeholder="请输入"
                        size="mini"
                        onkeyup="value=value.replace(/[^\d]/g,'')"
                        @blur="statistics(row)"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="缴库箱数"
                    prop="handInBoxs"
                    show-overflow-tooltip
                    min-width="90"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.handInBoxs"
                        :disabled="canDiable || row.cartonSizeName === '无纸箱'"
                        placeholder="请输入"
                        size="mini"
                        onkeyup=" value=value.replace(/[^\d]/g,'');if(value < 1) {value=1;row.handInBoxs = 1}  "
                      />
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="公斤数"
                    prop="kilogramQuantity"
                    show-overflow-tooltip
                    min-width="90"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.kilogramQuantity"
                        :disabled="canDiable"
                        placeholder="请输入"
                        size="mini"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="handInMxRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.handInMxRemark"
                        :disabled="canDiable"
                        placeholder="请输入"
                        size="mini"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    v-if="!canDiable"
                    label="操作"
                    fixed="right"
                    show-overflow-tooltip
                    min-width="80"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-tooltip
                        class="item"
                        effect="dark"
                        content="删除"
                        placement="right-start"
                      >
                        <span
                          class="pointer"
                          @click="purchaseDelete(scope.$index)"
                          ><i class="el-icon-delete"
                        /></span>
                      </el-tooltip>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
          </div>
        </div>
        <productStock ref="productStock" :productNo="productNo"></productStock>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="handleProductStock">成品库存</el-button>
          <el-button v-if="opsid === 2" size="mini" @click="handlePrint"
            >打印</el-button
          >
          <el-button size="mini" @click="isAddProduct = false">取 消</el-button>
          <!-- 新增       -->
          <el-button
            v-if="opsid !== 2"
            :loading="addProductLoading"
            :disabled="addProductLoading"
            element-loading-spinner="el-icon-loading"
            type="primary"
            size="mini"
            @click="savell"
            >{{ btm }}</el-button
          >
        </div>
      </el-dialog>
      <el-dialog
        append-to-body
        title="选择成品规格"
        :visible.sync="isSemidialog"
        :close-on-click-modal="false"
        custom-class="bodyNoPadDialog bigDialog"
        width="70%"
        @close="closeSemiDialog"
        @open="openmater"
      >
        <div class="dialogDody marDialog flex flex_column">
          <div class="btnCon flex flex_between">
            <!--      搜索框-->
            <el-button
              type="primary"
              size="mini"
              icon="el-icon-plus"
              @click="addPackge"
              >新建</el-button
            >
            <div class="search">
              <el-input
                v-model="SemiSearch.likeWords"
                placeholder="输入关键字"
                size="small"
              >
                <el-button
                  slot="append"
                  :loading="marLoading"
                  type="primary"
                  icon="el-icon-search"
                  :disabled="marLoading"
                  element-loading-spinner="el-icon-loading"
                  @click="openmater"
                >
                  搜索
                </el-button>
              </el-input>
            </div>
          </div>

          <!--    高级搜索版块-->
          <div class="seniorSearch flex flex_between">
            <div>
              <el-radio-group
                v-model="isExclusive"
                size="mini"
                @change="changeExclusive"
              >
                <el-radio-button label="1">专属</el-radio-button>
                <el-radio-button label="0">公用</el-radio-button>
              </el-radio-group>
            </div>
          </div>
          <!-- 表格区域       -->
          <div class="tableCon">
            <el-table
              :data="materialList"
              border
              style="width: 100%"
              @selection-change="handleSelectionChange"
            >
              <el-table-column prop="selection" width="55">
                <el-table-column type="selection" width="55" />
                <el-table-column prop="cartonSizeName" label="纸箱规格" />
                <el-table-column prop="packageDescription" label="包装描述" />
                <el-table-column prop="eachBoxQuantity" label="每箱数量" />
                <el-table-column prop="boxWeight" label="纸箱重量"/>
                <el-table-column prop="eachBoxNetWeight" label="每箱净重"/>
                <el-table-column prop="individualWeight" label="单个重量"/>
                <el-table-column prop="isExclusive" label="规格所属">

                  <template slot-scope="scope">
                    {{ scope.row.isExclusive ? "专属" : "公用" }}
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  fixed="right"
                  show-overflow-tooltip
                  min-width="80"
                  align="center"
                >
                  <template slot-scope="scope">
                    <el-tooltip
                      v-if="!canDiable"
                      class="item"
                      effect="dark"
                      content="删除"
                      placement="right-start"
                    >
                      <span
                        class="pointer"
                        @click="pakegeDelete(scope.row, scope.$index)"
                        ><i class="el-icon-delete"
                      /></span>
                    </el-tooltip>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="isSemidialog = false">取 消</el-button>
          <!-- 选择 -->
          <el-button
            v-loading="addLoading"
            :disabled="addLoading"
            element-loading-spinner="el-icon-loading"
            type="primary"
            size="mini"
            @click="saveColorManuscript"
          >
            确定</el-button
          >
        </div>
      </el-dialog>
      <!-- 原因   -->
      <el-dialog
        title="作废原因"
        :visible.sync="isNopassshow"
        :close-on-click-modal="false"
        custom-class="comDialog"
        width="40%"
        @close="closePassDialog"
      >
        <div class="dialogDody">
          <el-form
            ref="passForm"
            :rules="passFormrules"
            :model="passForm"
            class="dialogForm"
          >
            <el-form-item class="mt12" prop="cancelReason">
              <el-input
                v-model="passForm.cancelReason"
                type="textarea"
                placeholder="请输入内容"
                :autosize="{ minRows: 6 }"
                size="mini"
              />
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" @click="isNopassshow = false">取 消</el-button>
          <el-button
            :disabled="addLoading"
            element-loading-spinner="el-icon-loading"
            type="primary"
            size="mini"
            @click="passSave"
            >提交</el-button
          >
        </span>
      </el-dialog>

      <!--  成品纸箱规格  -->
      <el-dialog
        :title="'新建规格'"
        :visible.sync="GGpakege"
        :close-on-click-modal="false"
        custom-class="comDialog "
        width="30%"
        @close="closepakegrDialog"
        @open="openpakege"
      >
        <div class="dialogDody">
          <div class="addWuliaoBox">
            <el-form
              ref="materForm"
              :model="materForm"
              :rules="materFormRules"
              label-width="80px"
              class="dialogForm dialogInlineForm"
            >
              <el-row>
                <el-col>
                  <el-form-item label="纸箱规格" prop="cartonSizeNo">
                    <el-select
                        filterable
                      v-model="materForm.cartonSizeNo"
                      placeholder="请选择"
                      size="mini"
                    >
                      <el-option
                        v-for="item in GGlist"
                        :key="item.objectCode"
                        :label="item.objectName"
                        :value="item.objectCode"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-col>
                <el-form-item label="包装描述" prop="packageDescription">
                  <el-input v-model="materForm.packageDescription" size="mini" />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="每箱数量" prop="eachBoxQuantity">
                  <el-input
                    v-model="materForm.eachBoxQuantity"
                    onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                    @blur="calculation"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="纸箱重量" prop="boxWeight">
                  <el-input
                    v-model="materForm.boxWeight"
                    type="number"
                    @blur="calculation"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="每箱净重" prop="eachBoxNetWeight">
                  <el-input
                    v-model="materForm.eachBoxNetWeight"
                    type="number"
                    @blur="calculation"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="单个重量" prop="individualWeight">
                  <el-input
                    v-model="materForm.individualWeight"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="规格所属" prop="isExclusive" class="mt5">
                  <el-switch
                    v-model="materForm.isExclusive"
                    active-color="#3F61F1FF"
                    inactive-color="#D2D5DAFF"
                    active-value="1"
                    inactive-value="0"
                  />
                  <span class="f14 C_999aaa">规格专属后只能该产品使用</span>
                </el-form-item>
              </el-col>
            </el-form>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="GGpakege = false">取 消</el-button>
          <el-button
            v-loading="addMaterrielLoading"
            :disabled="addMaterrielLoading"
            element-loading-spinner="el-icon-loading"
            type="primary"
            size="mini"
            @click="savePackege"
            >保存</el-button
          >
        </div>
      </el-dialog>

      <!--  半成品成品纸  -->
      <el-dialog
        :title="'新建半成品'"
        :visible.sync="BCPpakege"
        :close-on-click-modal="false"
        custom-class="comDialog "
        width="30%"
        @close="bcpclosepakegrDialog"
        @open="openbcppakege"
      >
        <div class="dialogDody">
          <div class="addWuliaoBox">
            <el-form
              ref="BCPForm"
              :model="BCPForm"
              :rules="BCPFormRules"
              label-width="80px"
              class="dialogForm dialogInlineForm"
            >
              <el-row>
                <el-col>
                  <el-form-item label="名称" prop="productName">
                    <el-input v-model="BCPForm.productName" size="mini" />
                  </el-form-item>
                </el-col>
                <el-col>
                  <el-form-item label="单位" prop="productUnit">
                    <el-select
                        filterable
                      v-model="BCPForm.productUnit"
                      placeholder="请选择"
                      size="mini"
                    >
                      <el-option
                        v-for="item in BCPunitList"
                        :key="item.objectValue"
                        :label="item.objectName"
                        :value="item.objectName"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-col>
                <el-form-item label="包含工艺" prop="finishedCrafts">
                  <el-select
                        filterable
                    v-model="BCPForm.finishedCrafts"
                    multiple
                    placeholder="请选择"
                    size="mini"
                  >
                    <el-option
                      v-for="item in Craftist"
                      :key="item.produceCraftNo"
                      :label="item.produceCraftName"
                      :value="item.produceCraftNo"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="备注" prop="productRemark">
                  <el-input
                    v-model="BCPForm.productRemark"
                    size="mini"
                    :rows="5"
                    type="textarea"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="客户专属" prop="isExclusive" class="mt5">
                  <el-switch
                    v-model="BCPForm.isPublic"
                    active-color="#3F61F1FF"
                    inactive-color="#D2D5DAFF"
                    active-value="0"
                    inactive-value="1"
                  />
                  <span class="f14 C_999aaa">只有该客户使用</span>
                </el-form-item>
              </el-col>
            </el-form>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="BCPpakege = false">取 消</el-button>
          <el-button
            v-loading="addMaterrielLoading"
            :disabled="addMaterrielLoading"
            element-loading-spinner="el-icon-loading"
            type="primary"
            size="mini"
            @click="saveBCPPackege"
            >保存</el-button
          >
        </div>
      </el-dialog>
      <!--半成品成品 -->
      <el-dialog
        append-to-body
        title="选择半成品"
        :visible.sync="isVisible"
        :close-on-click-modal="false"
        custom-class="bodyNoPadDialog bigDialog"
        width="70%"
        @close="closeMarDialog"
        @open="openorder"
      >
        <div class="dialogDody marDialog flex flex_column">
          <div class="btnCon flex flex_between">
            <!--      搜索框-->
            <el-button
              type="primary"
              size="mini"
              icon="el-icon-plus"
              @click="addhaftPackge"
              >新建</el-button
            >
            <div class="search">
              <el-input
                v-model="materalSearch.likeWords"
                placeholder="输入关键字"
                size="small"
              >
                <el-button
                  slot="append"
                  v-loading="marLoading"
                  type="primary"
                  icon="el-icon-search"
                  :disabled="marLoading"
                  element-loading-spinner="el-icon-loading"
                  @click="openorder"
                >
                  搜索
                </el-button>
              </el-input>
            </div>
          </div>
          <!--    高级搜索版块-->
          <div class="seniorSearch flex flex_between">
            <div>
              <el-radio-group
                v-model="isPublic"
                size="mini"
                @change="changePublic"
              >
                <el-radio-button label="0">专属</el-radio-button>
                <el-radio-button label="1">公用</el-radio-button>
              </el-radio-group>
            </div>
          </div>
          <!-- 表格区域       -->
          <div class="tableCon">
            <el-table :data="bcpList" border style="width: 100%">
              <el-table-column prop="selection" width="55">
                <template slot-scope="scope">
                  <el-radio
                    v-model="radio"
                    :label="scope.$index"
                    @change.native="getCurrentRow(scope.row)"
                    >{{
                  }}</el-radio>
                </template>
              </el-table-column>
              <el-table-column prop="productName" label="半成品名称" />
              <el-table-column prop="productUnit" label="单位" />
              <el-table-column prop="finishedCraftNames" label="包含工艺" />
              <el-table-column
                prop="customerName"
                width="150"
                show-overflow-tooltip
                label="客户所属"
              />
              <el-table-column
                prop="productRemark"
                width="150"
                show-overflow-tooltip
                label="备注"
              />
              <el-table-column label="操作" width="80" align="center">
                <template slot-scope="scope">
                  <el-tooltip
                    v-if="!canDiable"
                    class="item"
                    effect="dark"
                    content="删除"
                    placement="right-start"
                  >
                    <span
                      class="pointer"
                      @click="hafpakegeDelete(scope.row, scope.$index)"
                      ><i class="el-icon-delete"
                    /></span>
                  </el-tooltip>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="isVisible = false">取 消</el-button>
          <!-- 选择 -->
          <el-button
            v-loading="addLoading"
            :disabled="addLoading"
            element-loading-spinner="el-icon-loading"
            type="primary"
            size="mini"
            @click="saveBCP"
          >
            确定</el-button
          >
        </div>
      </el-dialog>

    </div>
  </template>
  <script>
  import { arraySort } from "@/utils";
  import HeadSeting from "@/components/HeadSeting";
  import Pagination from "@/components/Pagination";
  import perRedioDialog from "@/components/perDialogRedio";
  import selectProductOrder from "@/components/selectProductOrder";
  import productStock from "@/components/productStock";
  import printModel from "./printModel.vue";
  import { mapGetters } from "vuex";
  import screec from "@/components/screen";
  import printBox from "./printBox.vue";

  export default {
    name: "Materiel",
    components: {
      Pagination,
      HeadSeting,
      perRedioDialog,
      selectProductOrder,
      printModel,
      productStock,
      screec,
      printBox,
    },
    data() {
      return {
        ops: "add", // 操作、新建，修改，查看
        opsid: 1, // 3 确定 1 新建， 4 修改， 2 查看
        isExclusive: 1,
        isPublic: 1,
        packageGuiGeType: 1, // 1 成品 2 半成品
        isVisible: false,
        GGpakege: false,
        selectOrder: {},
        tableHeight: null, // 表格最大高度
        showOrder: false,
        isSeeMaterriel: false, // 查看弹框是否打开
        isAddMaterriel: false, // 新建弹框是否打开
        addMaterrielLoading: false, // 新建保存加载
        searchLoading: false, // 搜索加载效果
        allMaterirls: [], // 全部数据列表
        colorState: null,
        addLoading: false,
        selectRow: null,
        productNo: "",
        isNopassshow: false,
        equipmentList: [],
        bcpList: [],
        passForm: {
          cancelReason: "",
        },
        BCPForm: {
          finishedCrafts: [],
        },
        boxList: [],
        prinftMass: {},
        // 表格操作
        ProductForm: {
          getMaterialType: 1,
          handInPersonName: "",
          productName: "",
          productNo: "",
          equipmentNo: "",
          customerName: "",
          mxDataList: [],
        },
        // 搜索条件
        materalSearch: {
          likeWords: "",
        },
        search: {
          QueryDataBaseFiled: "",
          pageIndex: 1,
          pageSize: 30,
          likeWords: "",
        },
        total: 0, // 总条数
        tableHead: [], // 表格表头
        addProductLoading: false,
        isAddProduct: false,
        isperShow: false,
        isSemidialog: false,
        multipleSelection: [],
        BCPpakege: false,
        purchaseInfoDatas: [{}],
        allSupliers: [],
        purchaseTypes: [
          {
            dicValueID: 0,
            dicValueDesc: "生产领料",
            dicValueCode: 1,
          },
          {
            dicValueID: 1,
            dicValueDesc: "生产补料",
            dicValueCode: 2,
          },
        ],
        SemiSearch: {
          likeWords: "",
        },
        materialList: [],
        marLoading: false,
        canDiable: false,
        Craftist: [],
        GGlist: [],
        selectBCP: "",
        radio: null,
        BCPunitList: [],
        materForm: {
          cartonSizeNo: "",
          packageDescription: "1箱*0包*0张*0[枚/套]",
          eachBoxQuantity: "",
          boxWeight:0,// 纸箱重量
          eachBoxNetWeight:0, //每箱净重
          individualWeight:'',  //单个净重

        },
        BCPFormRules: {
          productName: [
            { required: true, message: "请输入名称", trigger: "change" },
          ],
          productUnit: [
            { required: true, message: "请输入单位", trigger: "change" },
          ],
          finishedCrafts: [
            { required: true, message: "请选择工艺", trigger: "change" },
          ],
        },
        materFormRules: {
          cartonSizeNo: [
            { required: true, message: "请选择设备", trigger: "change" },
          ],
        },
        passFormrules: {
          cancelReason: [
            { required: true, message: "请输入原因", trigger: "change" },
          ],
        },
        rules: {
          handInPersonName: [
            { required: true, message: "请选择人员", trigger: "change" },
          ],
          productName: [
            { required: true, message: "请选择产品", trigger: "change" },
          ],
        },
      };
    },
    computed: {
      ...mapGetters(["name", "userInfo"]),
      btm() {
        if (this.opsid === 3) {
          return "确认";
        } else {
          return "保存";
        }
      },
      tname() {
        if (this.opsid === 1) {
          return "新建缴库单";
        } else if (this.opsid === 2) {
          return "查看缴库单";
        } else if (this.opsid === 3) {
          return "确定缴库单";
        } else if (this.opsid === 4) {
          return "修改缴库单";
        } else {
          return "复制缴库单";
        }
      },
    },
    created() {
      //  所有列表数据
      this.getAllMaterils();
      // 表格得表头
      this.getTableHead();
    },
    mounted() {
      // 表格高度
      this.calHeight();
    },
    updated() {
      this.$nextTick(() => {
        this.$refs.multipleTable.doLayout();
      });
    },
    methods: {
      //  半成品
      // 新建半成品
      getCurrentRow(row) {
        this.selectBCP = row;
      },
      saveBCP() {
        this.ProductForm.productName = this.selectBCP.productName;
        this.ProductForm.productNo = this.selectBCP.productNo;
        this.ProductForm.productUnionName = this.selectBCP.productUnit;
        this.ProductForm.productUnit = this.selectBCP.productUnit;
        // if (this.selectBCP.isPublic === 0) {
        //   this.ProductForm.customerName = '无'
        //   this.ProductForm.customerCode = ''
        // }
        this.closeMarDialog();
        // item.isChecked = !item.isChecked

        // const array = JSON.parse(JSON.stringify(this.ProductForm.mxDataList))
        // const arr = JSON.parse(JSON.stringify(this.selectBCP))

        // const isChecked = array.some((m) => m.employeeCode === arr.employeeCode)
        // if (!isChecked) {
        //   this.ProductForm.mxDataList.push(arr)
        // }
        // this.closeSemiDialog()sd
      },
      bcpclosepakegrDialog() {
        this.$refs.BCPForm.resetFields();
        this.BCPpakege = false;
      },

      statistics(row){
        row.kilogramQuantity = 0
        row.handInBoxs = row.handInQuantity/row.eachBoxQuantity
        row.kilogramQuantity = (row.handInQuantity*row.eachBoxQuantity)+(row.handInBoxs*row.kilogramQuantity)
      },


      //计算规格单个重量
      calculation(){
        this.materForm.individualWeight = (this.materForm.eachBoxNetWeight-this.materForm.boxWeight)/this.materForm.eachBoxQuantity
      },

      //点击成品库存
      handleProductStock() {
        this.productNo = this.ProductForm.productNo;
        this.$refs.productStock.isVisible = true;
      },

      handlePrint() {
        const { mxDataList, ...basedata } = this.ProductForm;
        this.prinftMass = {
          mxDataList: mxDataList,
          basedata: basedata,
        };
        console.log(this.prinftMass);
        setTimeout(() => {
              this.$print(this.$refs.printModel, {
                onPrint: ".noPrint",
                onStart: () => {
                  console.log("打印开始");
                },
                onEnd: () => {},
              });
            }, 300);
        // var printHtml = document.getElementById("print-iframe-ll").innerHTML;
        // var wind = window.open(
        //   "",
        //   "newwindow",
        //   " top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no"
        // );
        // wind.document.body.innerHTML = printHtml;
        // wind.print();
      },
      //  获取 单位和工艺
      openbcppakege() {
        this.$api.product.QueryGoodsUnitDataList().then((res) => {
          this.BCPunitList = res;
          // this.BCPForm.productUnit = res[0].objectCode
        });
        this.$api.product
          .GetProduceCraftsForOrder({
            saleOrderNo: this.selectOrder.orderNo,
          })
          .then((res) => {
            this.Craftist = res;
          });
      },
      addhaftPackge() {
        this.BCPpakege = true;
      },
      changePublic() {
        this.openorder();
      },
      addbcp() {
        this.isVisible = true;
      },
      closeMarDialog() {
        this.isVisible = false;
      },
      hafpakegeDelete(row, index) {
        const _data = {
          productID: row.productID,
        };
        this.$confirm("确定删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$api.product.DeleteSemiFinishedProduct(_data).then((res) => {
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.openorder();
            });
          })
          .catch(() => {});
      },
      openorder() {
        this.radio = null;
        const _data = {
          customerCode: this.selectOrder.customerCode,
          isPublic: Boolean(Number(this.isPublic)),
          likeWords: this.materalSearch.likeWords,
        };
        this.$api.product
          .GetMatchBaseSemiFinishedProductList(_data)
          .then((res) => {
            this.bcpList = res;
            // this.materForm.cartonSizeNo = res[0].objectCode
          });
      },
      // 成品
      closePassDialog() {
        this.passForm.cancelReason = "";
        this.selectRow = null;
      },
      checkProductList(row) {
        this.$router.push({
          path: "/business/orderDetail", // 跳转的路径
          query: {
            tabIndex: 6,
            orderNo: row.saleOrderNo,
            saleOrderNo: row.saleOrderNo,
          },
        });
      },
      changeExclusive() {
        this.openmater();
      },
      addPackge() {
        this.GGpakege = true;
      },

      handlePacking() {
        if (!this.ProductForm.productName) {
          this.$message.warning("请先选择产品名称！");
          return;
        } else {
          this.isSemidialog = true;
        }
      },

      //打印装箱单
      handlePrintBox(row) {
        this.$api.product
          .GetProduceHandInBillsZxBoxBillList({ handInBillNo: row.handInBillNo })
          .then((res) => {
            this.boxList = res;
            setTimeout(() => {
              this.$print(this.$refs.printBox, {
                onPrint: ".noPrint",
                onStart: () => {
                  console.log("打印开始");
                },
                onEnd: () => {},
              });
            }, 300);
          });
      },

      // 删除规格
      pakegeDelete(row, index) {
        const _data = {
          packageGuiGeID: row.packageGuiGeID,
        };
        this.$confirm("确定删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$api.product.DeleteProductPackageGuiGe(_data).then((res) => {
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.openmater();
            });
          })
          .catch(() => {});
      },
      // 新建规格
      openpakege() {
        if (this.$refs.materForm) {
          this.$refs.materForm.resetFields();
        }
        this.materForm = this.$options.data().materForm;
        this.$api.product.QueryPackageBoxGuiGeDataList().then((res) => {
          this.GGlist = res;
          this.materForm.cartonSizeNo = res[0].objectCode;
        });
        this.$api.product
          .GetOrderProductPackageInfoByOrderNo({
            SaleOrderNo: this.ProductForm.saleOrderNo,
          })
          .then((res) => {
            if (res.packageDescription || res.eachBoxQuantity) {
              this.materForm.packageDescription = res.packageDescription;
              this.materForm.eachBoxQuantity = res.eachBoxQuantity;
            }
          });
      },
      closepakegrDialog() {
        this.GGpakege = false;
      },
      saveBCPPackege() {
        this.$refs.BCPForm.validate((valid) => {
          if (valid) {
            const a = JSON.parse(JSON.stringify(this.BCPForm));
            a.customerCode = this.selectOrder.customerCode;
            a.productCode = this.selectOrder.productCode;
            a.saleOrderNo = this.selectOrder.orderNo;
            a.isPublic = Boolean(Number(a.isPublic));
            this.$api.product.CreateSemiFinishedProduct(a).then((res) => {
              this.$message({
                message: "新建成功",
                type: "success",
              });
              this.BCPpakege = false;
              this.openorder();
            });
          }
        });
      },
      // 保存规格
      savePackege() {
        this.materForm.customerCode = this.selectOrder.customerCode;
        this.materForm.productCode = this.selectOrder.productCode;
        this.materForm.isExclusive = Number(this.materForm.isExclusive);
        this.materForm.eachBoxQuantity = Number(this.materForm.eachBoxQuantity);
        this.materForm.packageGuiGeType = Number(this.packageGuiGeType);
        this.$api.product
          .CreateProductPackageGuiGe(this.materForm)
          .then((res) => {
            this.$message({
              message: "新建规格成功",
              type: "success",
            });
            this.openmater();
            this.GGpakege = false;
          });
      },
      // 获取规格
      getGGlist() {},
      // 新建点击事件
      newAddClick() {
        this.ops = "add";
        // this.isAddProduct = true
        this.opsid = 1;
        this.showOrder = true;
        this.canDiable = false;
        this.packageGuiGeType = 1;
        this.ProductForm.handInPersonName = this.userInfo.employeeName;
        this.ProductForm.handInPerson = this.userInfo.employeeCode;
      },
      newAddhalfClick() {
        this.opsid = 1;
        this.showOrder = true;
        this.canDiable = false;
        this.packageGuiGeType = 2;
        this.ProductForm.handInPersonName = this.userInfo.employeeName;
        this.ProductForm.handInPerson = this.userInfo.employeeCode;
      },
      handleClick(row) {
        this.opsid = 2;
        this.canDiable = true;
        this.getDetail(row);
      },
      handleConfirm(row) {
        this.opsid = 3;
        this.canDiable = true;
        this.getDetail(row);
      },
      handleDone(row) {
        this.selectRow = row;
        this.isNopassshow = true;
      },
      handleCopy(row) {
        this.opsid = 5;
        this.packageGuiGeType = row.handInType;
        // this.getDetail(row)
        // this.openCp()
        this.canDiable = false;
        const _data = {
          handInID: row.handInID,
          handInBillNo: row.handInBillNo,
        };
        this.$api.product.GetProductHandInBillDetail(_data).then((res) => {
          delete res.handInID;
          delete res.handInBillNo;
          this.ProductForm = res.baseData;
          // this.ProductForm.handInPerson = this.ProductForm.handInPersonNo
          this.ProductForm.mxDataList = res.mxDataList;
          this.isAddProduct = true;
        });
      },
      getDetail(row) {
        const _data = {
          handInID: row.handInID,
          handInBillNo: row.handInBillNo,
        };
        this.$api.product.GetProductHandInBillDetail(_data).then((res) => {
          this.ProductForm = res.baseData;
          // this.ProductForm.handInPerson = this.ProductForm.handInPersonNo
          this.ProductForm.mxDataList = res.mxDataList;
          this.prinftMass = res;
          this.ProductForm.productVersion =
            res.baseData.printingSurface + res.baseData.productVersion;
          this.isAddProduct = true;
        });
      },
      handleUpdata(row) {
        // this.selectOrder = row
        this.selectOrder.customerCode = row.customerCode;
        this.selectOrder.productCode = row.productNo;
        this.opsid = 4;
        this.canDiable = false;
        this.packageGuiGeType = row.handInType;
        this.getDetail(row);
      },
      passSave() {
        const _data = {
          handInID: this.selectRow.handInID,
          cancelReason: this.passForm.cancelReason,
        };
        this.$refs.passForm.validate((valid) => {
          if (valid) {
            this.$api.product
              .CancelProductHandInBill(_data)
              .then(() => {
                this.getAllMaterils();
                this.isNopassshow = false;
                this.addLoading = false;
                this.$message({
                  message: "作废成功",
                  type: "success",
                });
              })
              .catch(() => {});
          }
        });
      },
      handleDelete(row) {
        this.packageGuiGeType = row.handInType;
        const _data = {
          handInID: row.handInID,
        };
        this.$confirm("确定删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.$api.product
            .DeleteProductHandInBill(_data)
            .then(() => {
              this.getAllMaterils();
              this.$message({
                message: "删除成功",
                type: "success",
              });
            })
            .catch(() => {});
        });
      },

      selectCurrentRow(row) {
        // this.productNo = row.productNo
        this.selectOrder = row;
        this.ops = "add";
        this.isAddProduct = true;
        this.ProductForm.produceTaskBillNo = row.produceTaskBillNo;
        this.ProductForm.saleOrderNo = row.orderNo;
        this.ProductForm.customerCode = row.customerCode;
        this.ProductForm.customerName = row.customerName;
        this.ProductForm.productUnionName = row.productUnion;
        this.ProductForm.handInType = this.packageGuiGeType;

        this.ProductForm.productCode = row.productCode;
        this.ProductForm.customerBillNo = row.customerBillNo;
        this.ProductForm.xieYiShuHao = row.xieYiShuHao;
        this.ProductForm.productVersion =
          row.printingSurface + row.productVersions;
        if (this.packageGuiGeType === 1) {
          this.ProductForm.orderProductName = row.orderProductName;
          this.ProductForm.productUnit = row.productUnion;
          this.ProductForm.productName = row.orderProductName;
          this.ProductForm.productNo = row.productNo;
          this.ProductForm.handInTypeName = "成品缴库";
          this.$api.product
            .GetProductsStockDataList({ productNo: row.productNo })
            .then((res) => {
              this.ProductForm.mxDataList = res;
            });
        } else {
          this.ProductForm.handInTypeName = "半成品缴库";
          this.ProductForm.mxDataList = [];
        }
      },

      purchaseDelete(index) {
        this.ProductForm.mxDataList.splice(index, 1);
      },
      // 规格列表
      openmater() {
        console.log(this.opsid);
        if (this.opsid == 1) {
          let _data = {
            customerCode: this.selectOrder.customerCode,
            productCode: this.selectOrder.productCode,
            packageGuiGeType: this.packageGuiGeType,
            isExclusive: Number(this.isExclusive),
            likeWords: this.SemiSearch.likeWords,
          };
          this.$api.product.GetMatchProductPackageGuiGeList(_data).then((res) => {
            this.materialList = res;
          });
        } else {
          let _data = {
            customerCode: this.selectOrder.customerCode,
            productCode: this.ProductForm.productCode,
            packageGuiGeType: this.packageGuiGeType,
            isExclusive: Number(this.isExclusive),
            likeWords: this.SemiSearch.likeWords,
          };
          this.$api.product.GetMatchProductPackageGuiGeList(_data).then((res) => {
            this.materialList = res;
          });
        }
      },

      openCp() {
        const _data = {
          produceTaskBillNo: this.ProductForm.produceTaskBillNo,
          likeWords: "",
        };
        this.$api.product.GetProduceTaskEquipmentList(_data).then((res) => {
          this.equipmentList = res;
          if (res && res.length) {
            this.ProductForm.equipmentNo = res[0].equipmentNo;
          }
        });
      },
      savell() {
        if (this.opsid === 3) {
          const _data3 = {
            handInID: this.ProductForm.handInID,
          };
          this.$api.product
            .SureProductHandInBill(_data3)
            .then(() => {
              this.addProductLoading = false;
              this.isAddProduct = false;
              this.getAllMaterils();
              this.$message({
                message: "确认成功",
                type: "success",
              });
            })
            .catch(() => {
              this.addProductLoading = false;
            });
        } else if (this.opsid === 4) {
          const parmas = this.ProductForm;
          parmas.handInPerson = this.ProductForm.handInPerson;
          if (parmas.mxDataList.length < 1) {
            this.$message.warning("请添加成品明细");
            return;
          }
          parmas.mxDataList.forEach((e) => {
            e.handInQuantity = Number(e.handInQuantity);
            e.kilogramQuantity = Number(e.kilogramQuantity);
            e.handInBoxs = Number(e.handInBoxs);
            e.productUnit = this.ProductForm.productUnionName;
            if (e.handInBoxs < 1 && e.cartonSizeName !== "无纸箱") {
              e.handInBoxs = 1;
            }
          });
          this.$refs.ProductForm.validate((valid) => {
            if (valid) {
              this.addProductLoading = true;
              this.$api.product
                .UpdateProductHandInBill(parmas)
                .then(() => {
                  this.addProductLoading = false;
                  this.isAddProduct = false;
                  this.getAllMaterils();
                  this.$message({
                    message: "修改成功",
                    type: "success",
                  });
                })
                .catch(() => {
                  this.addProductLoading = false;
                });
            }
          });
        } else {
          const parmas = this.ProductForm;
          parmas.handInType = this.packageGuiGeType;
          if (parmas.mxDataList.length < 1) {
            this.$message.warning("请添加成品明细");
            return;
          }
          parmas.mxDataList.forEach((e) => {
            e.handInQuantity = Number(e.handInQuantity);
            e.kilogramQuantity = Number(e.kilogramQuantity);
            e.handInBoxs = Number(e.handInBoxs);
            e.productUnit = this.ProductForm.productUnionName;
            if (e.handInBoxs < 1 && e.cartonSizeName !== "无纸箱") {
              e.handInBoxs = 1;
            }
          });
          this.$refs.ProductForm.validate((valid) => {
            if (valid) {
              this.addProductLoading = true;
              this.$api.product
                .CreateProductHandInBill(parmas)
                .then(() => {
                  this.addProductLoading = false;
                  this.isAddProduct = false;
                  this.getAllMaterils();
                  this.$message({
                    message: "保存成功",
                    type: "success",
                  });
                })
                .catch(() => {
                  this.addProductLoading = false;
                });
            }
          });
        }
      },

      // 得到申请人员
      getEmployee(val) {
        this.ProductForm.handInPersonName = val.employeeName;
        this.ProductForm.handInPerson = val.employeeCode;
        this.ProductForm.getMaterialPerson = val.employeeCode;
      },
      supplierChange(val) {
        this.materSearch.supplierCode = val;
        this.purchaseInfoDatas = [];
      },
      closeSemiDialog() {
        this.isSemidialog = false;
      },
      MarterdialogShow() {},
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      saveColorManuscript() {
        console.log(this.multipleSelection);
        if (this.multipleSelection.length < 1) {
          this.$message.warning("请选择成品!");
          return;
        }
        const array = JSON.parse(JSON.stringify(this.ProductForm.mxDataList));
        const arr = JSON.parse(JSON.stringify(this.multipleSelection));
        arr.forEach((item) => {
          if (item.cartonSizeName === "无纸箱") {
            item.handInBoxs = 0;
          } else {
            item.handInBoxs = 1;
          }
          item.getMaterialRemark = "";
        });
        this.ProductForm.mxDataList = arr.reduce((result, item) => {
          const val = result.some(
            ({ packageGuiGeNo }) => packageGuiGeNo === item.packageGuiGeNo
          );
          if (!val) {
            result.push(item);
          }
          return result;
        }, array);
        this.closeSemiDialog();
      },
      // 详情
      getMaterielInfo(id) {},
      // 保存表头样式变化
      saveHead(newArray) {
        const parmas = newArray;
        setTimeout(() => {
          this.$api.common.saveTableStyle(parmas).then(() => {});
        }, 300);
      },
      // 保存表头列宽度
      surverWidth(newWidth, oldWidth, column) {
        setTimeout(() => {
          const heads = [...this.tableHead];
          heads.forEach((item) => {
            if (item.columnCode === column.property) {
              item.columnWidth = column.width;
              return;
            }
          });
          this.saveHead(heads);
        }, 100);
      },
      // 表格最大高度
      calHeight() {
        this.$nextTick(() => {
          const rect = this.$refs.tableCon.getBoundingClientRect();
          this.tableHeight = rect.height;
        });
      },
      // ，清除所有查询条件
      Refresh() {
        this.search = this.$options.data().search;
        this.getAllMaterils();
      },
      // 获取表格表头
      getTableHead() {
        const parmas = {
          tableCode: this.$config.producehandinbilllist,
        };
        this.$api.common.getAllTableHead(parmas).then((res) => {
          res.sort(arraySort("columnSort"));
          this.tableHead = res;
        });
      },
      // 所有列表数据
      getAllMaterils() {
        const parmas = this.search;
        this.searchLoading = true;
        this.$api.product
          .GetPageProductHandInBills(parmas)
          .then((res) => {
            this.allMaterirls = res.list;
            this.allMaterirls.forEach((item) => {
              for (let i in item) {
                if (!item[i] && item[i] !== 0) {
                  item[i] = "--";
                }
              }
            });
            this.total = res.totalCount;
            this.searchLoading = false;
          })
          .catch(() => {
            this.searchLoading = false;
          });
      },
      // 新建弹框关闭事件
      closeDialog() {
        if (this.$refs.ProductForm) {
          this.$refs.ProductForm.resetFields();
        }
        this.ProductForm = this.$options.data().ProductForm;
      },
    },
  };
  </script>
  <style lang="scss" scoped>
  .container {
    height: 100%;
  }
  .permangeRg {
    border: 1px solid #e6e6e6;
    background: #fff;
    height: 100%;

    .mainTT {
      font-size: 16px;
      font-weight: bold;
      width: 100%;
      padding: 18px 16px;
      padding-bottom: 0;
    }
  }
  .addWuliaoBox {
    padding: 10px 16px;

    .tableBox {
      margin-top: 16px;
      border: 1px solid #e6e6e6;
      border-bottom: none;
      border-radius: 8px 8px 0 0;
      overflow: hidden;

      .tt {
        height: 38px;
        line-height: 38px;
        padding-left: 16px;
        background: #f7f8fa;
        border-radius: 8px 8px 0 0;
      }
    }
  }

  .subTip {
    border-bottom: 1px #e6e6e6 solid;
    background: #f5f6f9;
    padding: 8px 16px;
  }

  .center {
    display: flex;
    align-items: center;
  }

  </style>
